package com.sayimo.maker.mall.goods.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sayimo.framework.database.mybatis.AbstractMybatisBaseDao;
import com.sayimo.framework.exception.DaoException;
import com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao;
import com.sayimo.maker.mall.goods.vo.GoodsNormsStock;
import com.sayimo.maker.mall.goods.vo.GoodsNormsValueStock;




@Repository(value="goodsNormsValueStockInterfaceDao")
public class GoodsNormsValueStockInterfaceImplDao extends AbstractMybatisBaseDao<GoodsNormsValueStock> implements GoodsNormsValueStockInterfaceDao{

	/**
	 * 
	 * @MethodName queryGoodsNormsValueStockByGoodsId
	 * @Description 按商品ID和规格ID查询
	 * 
	 * @author chenpy
	 * @date 2016年1月5日 下午3:46:46
	 * @param
	 * @return GoodsNormsValueStock
	 * @VERSION 1.0.0
	 */
	public GoodsNormsValueStock queryGoodsNormsValueStockByGoodsId(GoodsNormsValueStock goodsNormsValueStock) throws DaoException {
		return this.mybatisInterfaceBaseDao.get("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.queryGoodsNormsValueStockByGoodsId", goodsNormsValueStock);
	}

	
	@Override
	public void updateAbatementGoodsNormsStockById(GoodsNormsStock goodsNormsStock) throws DaoException {
		mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateAbatementGoodsNormsStockById", goodsNormsStock);
	}


	@Override
	public Integer queryGoodsNormsValueStockByGoodsIdNormsValueId(Map<String, Object> pm) throws DaoException {
		Object object = mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.queryGoodsNormsValueStockByGoodsIdNormsValueId", pm);
		if(object != null){
			return (Integer)object;
		}
		return 0;
	}

	/**
	 * 
	 * @MethodName queryGoodsNormsValueStockByGoodsId
	 * @Description 商品详情切换规格
	 * 
	 * @author chenpy
	 * @date 2016年1月5日 下午3:46:46
	 * @param
	 * @return GoodsNormsValueStock
	 * @VERSION 1.0.0
	 */
	public Map<String, Object> changeGoodsNormsValue(Map<String, Object> paramMap) throws DaoException {
		return this.mybatisInterfaceBaseDao.queryMap("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.changeGoodsNormsValue", "id", paramMap);
	}


	public int batchUpdateGoodsStock(List list) throws DaoException {
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.batchUpdateGoodsStock", list);
	}


	@Override
	public Map<String,Object> getFirstGoodsNormsValueStockByGoodsId(Integer goodsId) throws DaoException {
		return (Map<String, Object>) this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.getFirstGoodsNormsValueStockByGoodsId", goodsId);
	}
	
	@Override
	public Map<String, Object> querySkuCodeByNomalId(Map<String, Object> paramMap) throws DaoException {
		return this.mybatisInterfaceBaseDao.queryMap("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.querySkuCodeByNomalId","skuCode",paramMap);
	}
	
	/**
	 * 
	* @Title: updateStockNum 
	* @Author: 田超
	* @Date:日期：2016年6月28日  时间：下午6:01:18
	* @Description: 更新商品的库存量
	* @param paramMap
	* @return
	* @throws DaoException
	* @return Integer
	* @Version 1.0.0
	 */
	public Integer updateStockNum(Map<String, Object> paramMap) throws DaoException {
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateStockNum",paramMap);
	}


	/** 
	  * @package com.sayimo.school.mall.service.goods
	  * @author wangyang
	  * @Title:  getNormsValueStockByMap
	  * @Description: 按ID获取GoodsNormsValueStock
	  * @param 
	  * @throws 
	  * @return GoodsNormsValueStock
	  * @date 2016年7月15日
	  */ 
	@Override
	public Map<String, Object> getNormsValueStockByMap(
			Map<String, Object> paramMap) throws DaoException {
		return this.mybatisInterfaceBaseDao.queryMap("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.getNormsValueStockByMap", "id", paramMap);
	}


	@Override
	public Integer updateActivityNumById(Integer ordersId) throws DaoException {
		Map<String, Object> map=new HashMap<String, Object> ();
		map.put("ordersId", ordersId);
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateActivityNumById",map);
	}
	
	@Override
	public Integer updateSeckillNumById(Integer ordersId) throws DaoException {
		Map<String, Object> map=new HashMap<String, Object> ();
		map.put("ordersId", ordersId);
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateSeckillNumById",map);
	}
	
	@Override
	public Integer updateCutPriceNumById(Integer ordersId) throws DaoException {
		Map<String, Object> map=new HashMap<String, Object> ();
		map.put("ordersId", ordersId);
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateCutPriceNumById",map);
	}


	@Override
	public Map<String, Object> getActivityStockNum(Map<String, Object> pm)
			throws DaoException {
		Object object = mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.getActivityStockNum", pm);
		return (Map<String, Object>)object;
	}


	/** 
	  * @package com.sayimo.school.mall.module.goods.dao
	  * @author chenpy
	  * @Title:  
	  * @Description: 获取订单中所有的特奢汇商品
	  * @param 
	  * @throws 
	  * @return List
	  * @date 2016年9月12日
	  */ 
	public List queryTSHGoodsInOrders(Integer[] ordersIds) throws DaoException{
		return mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.queryTSHGoodsInOrders", ordersIds);
	}
	
	/** 
	  * @package com.sayimo.school.mall.module.goods.dao
	  * @author chenpy
	  * @Title:  
	  * @Description: 判断普通商品库存
	  * @param 
	  * @throws 
	  * @return List
	  * @date 2016年9月13日
	  */ 
	public List queryLackStockGoodsInfoInOrders(Integer ordersId[]) throws DaoException{
		return mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.queryLackStockGoodsInfoInOrders", ordersId);
	}
	
	/** 
	  * @package com.sayimo.school.mall.module.goods.dao
	  * @author chenpy
	  * @Title:  
	  * @Description: 获取订单下商品的可发货地址信息(判断用户指定地址是否支持发货)
	  * @param 
	  * @throws 
	  * @return List
	  * @date 2016年9月14日
	  */ 
	public List queryOrdersLogistics(Map paramMap) throws DaoException{
		return mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.queryOrdersLogistics", paramMap);
	}
	/**
	 * @Package com.sayimo.school.mall.module.goods.dao.impl
	 * @Author TANXIN
	 * @MethodName:getSeckillStockNum
	 * @Description:获取秒抢活动商品数量
	 * @param pm
	 * @return
	 * @throws DaoException
	 * @Date 2016年10月18日,下午2:42:34
	 */
	@Override
	public Map<String, Object> getSeckillStockNum(Map<String, Object> pm)
			throws DaoException {
		Object object = mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.getSeckillStockNum", pm);
		return (Map<String, Object>)object;
	}


	@Override
	public Integer updateReturnActivityNumById(Integer ordersId)
			throws DaoException {
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateReturnActivityNumById", ordersId);
	}


	@Override
	public Integer updateReturnSeckillNumById(Integer ordersId)
			throws DaoException {
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateReturnSeckillNumById", ordersId);
	}
	/**
	 * @Package com.sayimo.school.mall.module.goods.dao.impl
	 * @Author TANXIN
	 * @MethodName:updateReturnSeckillNumById
	 * @Description:取消订单返还砍价库存
	 * @param ordersId
	 * @return
	 * @throws DaoException
	 * @Date 2016年10月24日,上午9:42:23
	 */
	@Override
	public Integer updateReturnCutPriceNumById(Integer ordersId)
			throws DaoException {
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateReturnCutPriceNumById", ordersId);
	}

	/** 
	* @Title: getGroupBuyStockNum 
	* @Description: 获取团购活动商品数量
	* @param paramMap
	* @return
	* @return Map<String,Object>
	* @throws 
	*/ 
	@Override
	public Map<String, Object> getGroupBuyStockNum(Map<String, Object> paramMap)
			throws DaoException {
		Object object = mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.getGroupBuyStockNum", paramMap);
		return (Map<String, Object>)object;
	}
	/**
	 * @Package com.sayimo.school.mall.module.goods.dao.impl
	 * @Author TANXIN
	 * @MethodName:getCutPriceStockNum
	 * @Description:砍价活动商品库存是否不足
	 * @param paramMap
	 * @return
	 * @throws DaoException
	 * @Date 2016年10月24日,上午9:24:04
	 */
	@Override
	public Map<String, Object> getCutPriceStockNum(Map<String, Object> paramMap)
			throws DaoException {
		Object object = mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.getCutPriceStockNum", paramMap);
		return (Map<String, Object>)object;
	}


	/** 
	* @Title: updateGroupBuyNumById 
	* @Description: 扣减团购商品表活动商品数量
	* @param id
	* @return void
	* @throws 
	*/ 
	@Override
	public Integer updateGroupBuyNumById(Integer ordersId) throws DaoException {
		Map<String, Object> map=new HashMap<String, Object> ();
		map.put("ordersId", ordersId);
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateGroupBuyNumById",map);	
	}


	/** 
	* @Title: updateReturnGroupBuyNumById 
	* @Description:返还团购库存 
	* @param id
	* @return Integer
	* @throws 
	*/ 
	@Override
	public Integer updateReturnGroupBuyNumById(Integer ordersId) throws DaoException {
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsNormsValueStockInterfaceDao.updateReturnGroupBuyNumById", ordersId);
	}
}
